package cn.tinlan.shopcoin.app.mine.set;

import android.graphics.Bitmap;
import android.view.View;
import android.widget.ImageView;

import com.hjq.bar.OnTitleBarListener;
import com.hjq.bar.TitleBar;
import com.yzq.zxinglibrary.encode.CodeCreator;

import butterknife.BindView;
import cn.tinlan.shopcoin.R;
import cn.tinlan.shopcoin.Utils.SPUtils;
import cn.tinlan.shopcoin.app.login.UserModel;
import cn.tinlan.shopcoin.base.BaseActivity;
import pub.devrel.easypermissions.EasyPermissions;

/**
 * Created by Mortimer on 2018/12/27. 09:50
 * 佛祖🙏，永无bug。
 */
public class QRCodeActivity extends BaseActivity {

    @BindView(R.id.set_qrcode_title)
    TitleBar titleBar;
    @BindView(R.id.set_qrcode_img)
    ImageView qrcodeIMG;
    @Override
    protected int provideContentViewId() {
        return R.layout.activity_qrcode;
    }

    @Override
    public void initView() {
        super.initView();

        drawableDefaultBar();

        initTitleView();
        initQRCodeImg();
    }

    private void initQRCodeImg() {



        UserModel userModel = SPUtils.getUserBean(QRCodeActivity.this);
        String r_code ="http://1.qsls888.com/index.php/Home/Register/index.html?r_code="+userModel.getR_code();
        Bitmap bitmap = CodeCreator.createQRCode(r_code, 400, 400, null);
        if (bitmap != null) {
            qrcodeIMG.setImageBitmap(bitmap);
        }

    }
    private void initTitleView() {
        titleBar.setOnTitleBarListener(new OnTitleBarListener() {
            @Override
            public void onLeftClick(View v) {
                finish();
            }

            @Override
            public void onTitleClick(View v) {

            }

            @Override
            public void onRightClick(View v) {

            }
        });
    }
}
